home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / vol6n14.arc / INSTALL.ASM < prev    next >
Assembly Source File  |  1987-08-16  |  5KB  |  110 lines

  1. ;INSTALL.COM for the IBM Personal Computer - 1987 by Jeff Prosise
  2. ;
  3. code          segment para public 'code'
  4.               assume cs:code
  5.               org 100h
  6. begin:        jmp install                   ;skip data area
  7. ;
  8. tsr_count          dw 0                     ;number of TSR's installed
  9. segment_table      dw 64 dup (?)            ;wedge program segments
  10. vector_table       db 1024 dup (?)          ;vector table storage area
  11. first_call         db 0                     ;INSTALL status flag
  12. old1Ah             label dword              ;storage for interrupt 1Ah vector
  13. old1Ah_vector      dw 2 dup (?)
  14. errmsg             db 13,10,'No room for more',13,10,'$'
  15. ;
  16. copyright          db 'Copyright 1987 Ziff-Davis Publishing Co.'
  17. author             db 'Jeff Prosise'
  18. ;
  19. ;------------------------------------------------------------------------------
  20. ;NEW1AH routine intercepts calls to interrupt 1Ah.  If the function code in AH
  21. ;is 44h, then the Installation Data Table (IDT) segment is returned in ES.
  22. ;------------------------------------------------------------------------------
  23. new1Ah        proc near
  24.               sti                           ;enable interrupts
  25.               cmp ah,44h                    ;is the function code 44h?
  26.               je new1Ah1                    ;yes, then handle the call here
  27.               jmp old1Ah                    ;jump to the real int 1Ah handler
  28. new1Ah1:      push cs                       ;place current code segment in ES
  29.               pop es
  30.               dec bh                        ;decrement BH to verify call
  31.               iret                          ;return to calling routine
  32. new1Ah        endp
  33. ;
  34. ;------------------------------------------------------------------------------
  35. ;INSTALL routine saves pertinent data needed for deinstallation.
  36. ;------------------------------------------------------------------------------
  37. install       proc near
  38.               assume ds:code
  39. ;
  40. ;Begin by determining if this is the first call to INSTALL.
  41. ;
  42.               mov ah,44h                    ;call int 1Ah, function 44h
  43.               xor bh,bh                     ;zero BH
  44.               int 1Ah
  45.               cmp bh,0FFh                   ;BH=0FFh?
  46.               je install1                   ;yes, then INSTALL is resident
  47.               mov first_call,1              ;no, then this is the first call
  48. ;
  49. ;See if there is room to record the installation of another TSR.
  50. ;
  51. install1:     mov di,offset tsr_count       ;point DI to installation count
  52.               cmp word ptr es:[di],32       ;still room for more TSR's?
  53.               jb install2                   ;yes, then continue
  54.               mov ah,9                      ;no, then print error message
  55.               lea dx,errmsg
  56.               int 21h
  57.               ret                           ;terminate
  58. ;
  59. ;Increment the count of TSR's installed and record current PSP and environment
  60. ;block segment values.
  61. ;
  62. install2:     mov ax,es:[di]                ;get TSR count in AX
  63.               inc word ptr es:[di]          ;increment count
  64.               mov cl,2                      ;multiply by 4
  65.               shl ax,cl
  66.               add ax,offset segment_table   ;complete offset address
  67.               mov di,ax                     ;transfer to DI
  68.               mov es:[di],cs                ;save current code segment value
  69.               mov ax,cs:[2Ch]               ;get env block segment from PSP
  70.               mov es:[di+2],ax              ;store it
  71. ;
  72. ;Copy the interrupt vector table from low memory into storage.
  73. ;
  74.               push ds                       ;save DS
  75.               xor ax,ax                     ;point DS:SI to int vector table
  76.               mov ds,ax
  77.               assume ds:nothing
  78.               xor si,si
  79.               push cs                       ;point ES:DI to storage area
  80.               pop es
  81.               lea di,vector_table
  82.               mov cx,512                    ;512 words to move
  83.               cld                           ;clear DF
  84.               cli                           ;suspend interrupts during move
  85.               rep movsw                     ;copy vector table
  86.               sti                           ;restore interrupts
  87.               pop ds                        ;restore DS
  88.               assume ds:code
  89. ;
  90. ;If INSTALL hasn't been called once before, reset the interrupt 1Ah vector.
  91. ;
  92.               cmp first_call,0              ;is this the first call?
  93.               je install3                   ;no, then skip ahead
  94.               mov ax,351Ah                  ;get old interrupt 1Ah vector
  95.               int 21h
  96.               mov old1Ah_vector,bx          ;store it
  97.               mov old1Ah_vector[2],es
  98.               mov ah,25h                    ;point vector to NEW16H routine
  99.               lea dx,new1Ah
  100.               int 21h
  101. ;
  102. ;Terminate-but-stay-resident.
  103. ;
  104. install3:     mov dx,offset install         ;point DX to end
  105.               int 27h                       ;terminate-but-stay-resident
  106. install       endp
  107. ;
  108. code          ends
  109.               end begin
  110.